﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin1_Default2 : System.Web.UI.Page
{
    //Datacon db = new Datacon();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //db.ecDropDownList(ddlCourse, "select * from Course where teacher_id='" + Session["ID"] + "'", "c_name", "c_id");          //初始化考试科目下拉列表框          
            //using (DataClassesDataContext ds = new DataClassesDataContext())
            //{
            //    ddlCourse.DataSource = from q in ds.Course select q;
            //    ddlCourse.DataTextField = "c_name";
            //    ddlCourse.DataValueField = "c_id";
            //    ddlCourse.DataBind();
            //}
        }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
       
        //db.eccom("insert into JudgeProblem(c_id,Title,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + rblAnswer.SelectedValue + "')");
        using (DataClassesDataContext ds = new DataClassesDataContext())
        {
            JudgeProblem p = new JudgeProblem();
            p.c_id =Convert.ToInt32( this.ddlCourse.DataValueField);
            p.Title = this.txtTitle.Text.Trim();
            p.Answer = Convert.ToBoolean(rblAnswer.SelectedValue);
            ds.JudgeProblem.InsertOnSubmit(p);
            ds.SubmitChanges();
        }
        Response.Write("<script>alert('添加成功！')</script>");
      
    }
}